﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace UpdateApp
{
    public partial class CheckChunk : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.Form["md5"]))
            {
                var filePath = Path.Combine(FileHelper.GetUploadPath(), DateTime.Now.ToString("yyyy-MM-dd"), Request.Form["md5"], Request.Form["chunk"]);

                //文件是否存在 若存在判断大小 相同无需上传
                if (File.Exists(filePath))
                {
                    FileInfo info = new FileInfo(filePath);
                    if (info.Length == long.Parse(Request.Form["chunkSize"]))
                    {
                        Response.Write("true");
                        Response.End();
                    }
                }

                Response.Write("false");
                Response.End();
            }
        }
    }
}